//
//  QUHomePageController.m
//  GuQu
//
//  Created by HELIUM STAR on 15/5/4.
//  Copyright (c) 2015年 HELIUM STAR. All rights reserved.
//

#import "GQHomePageController.h"
#import "GQLoginController.h"
#import "GQNavigationController.h"
#import "GQRegisterController.h"

#define kBtnMargin 20 * kHRate
#define kBtnHeight 44
#define kBtnBottomMargin 150 * kHRate

@interface GQHomePageController ()

@property (weak, nonatomic) UIButton *loginBtn;

@end

@implementation GQHomePageController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setUpLoginInBtn];
}

- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
}

- (void)setUpLoginInBtn
{
    //创建启动页面的图标
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"profile_setting"]];
    imageView.frame = CGRectMake((self.view.width - 200 * kVRate) / 2, 106 * kVRate, 200 * kVRate, 200 * kVRate);
    [self.view addSubview:imageView];
    
    
    UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    loginBtn.x = kBtnMargin;
    loginBtn.y = kScreenHeight - kBtnBottomMargin - kBtnHeight;
    loginBtn.width = kScreenWidth - 2 * kBtnMargin;
    loginBtn.height = kBtnHeight;
    [self.view addSubview:loginBtn];
    [loginBtn setTitle:@"登录" forState:UIControlStateNormal];
    [loginBtn setBackgroundColor:kLoginBtnColor];
    loginBtn.layer.masksToBounds = YES;
    loginBtn.layer.cornerRadius = 5;
    loginBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [loginBtn addTarget:self action:@selector(loginBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
    self.loginBtn = loginBtn;
    
    UIButton *registerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    registerBtn.x = kBtnMargin;
    registerBtn.y = CGRectGetMaxY(loginBtn.frame) + 10;
    registerBtn.width = kScreenWidth - 2 * kBtnMargin;
    registerBtn.height = kBtnHeight;
    [self.view addSubview:registerBtn];
    [registerBtn setTitle:@"注册" forState:UIControlStateNormal];
    [registerBtn setTitleColor:kLoginBtnColor forState:UIControlStateNormal];
    registerBtn.layer.masksToBounds = YES;
    registerBtn.layer.cornerRadius = 5;
    registerBtn.layer.borderColor = kLoginBtnColor.CGColor;
    registerBtn.layer.borderWidth = 1;
    registerBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [registerBtn addTarget:self action:@selector(registerBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
    self.loginBtn = registerBtn;
    
}

- (void)loginBtnDidClick
{
    GQLoginController *GQLC = [[GQLoginController alloc] init];
    [self.navigationController pushViewController:GQLC animated:YES];
}

- (void)registerBtnDidClick
{
    GQRegisterController *GQRC = [[GQRegisterController alloc] init];
    [self.navigationController pushViewController:GQRC animated:YES];
}


@end
